<?php

/**
 * This is the model class for table "data_npwpd".
 *
 * The followings are the available columns in table 'data_npwpd':
 * @property string $nomor_urut
 * @property string $no_formulir
 * @property string $npwpd
 * @property string $nama_npwpd
 * @property string $alamat_npwpd
 * @property string $rt_npwpd
 * @property string $rw_npwpd
 * @property string $kelurahan_npwpd
 * @property string $kecamatan_npwpd
 * @property string $kabupaten_npwpd
 * @property string $nopd
 * @property string $tanggal_pendataan
 * @property string $petugas_pendataan
 * @property string $nip_pendataan
 * @property string $petugas_pencatatan
 * @property string $nip_pencatatan
 * @property string $cara_hitung
 * @property string $p_hotel
 * @property string $p_restoran
 * @property string $p_hiburan
 * @property string $p_reklame
 * @property string $p_ppj
 * @property string $p_gol_c
 * @property string $p_abt
 * @property string $p_parkir
 * @property string $wp
 * @property string $status_aktif
 * @property string $user_operator
 *
 * The followings are the available model relations:
 * @property SptpdAirtanah[] $sptpdAirtanahs
 * @property SptpdHiburan[] $sptpdHiburans
 * @property SptpdReklame[] $sptpdReklames
 * @property SptpdRestoran[] $sptpdRestorans
 * @property SuratIzinbWpBu[] $suratIzinbWpBus
 * @property SptpdParkir[] $sptpdParkirs
 * @property SptpdHotel[] $sptpdHotels
 * @property DetailRestoran[] $detailRestorans
 * @property DetailHotel[] $detailHotels
 * @property SptpdGalianc[] $sptpdGaliancs
 */
class DataNpwpd extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'data_npwpd';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nomor_urut', 'required'),
			array('nomor_urut, no_formulir, npwpd', 'length', 'max'=>15),
			array('nama_npwpd', 'length', 'max'=>50),
			array('alamat_npwpd', 'length', 'max'=>125),
			array('rt_npwpd, rw_npwpd', 'length', 'max'=>3),
			array('kelurahan_npwpd, kecamatan_npwpd, petugas_pencatatan', 'length', 'max'=>45),
			array('kabupaten_npwpd, user_operator', 'length', 'max'=>35),
			array('nopd, nip_pendataan, nip_pencatatan', 'length', 'max'=>20),
			array('petugas_pendataan', 'length', 'max'=>75),
			array('cara_hitung', 'length', 'max'=>10),
			array('p_hotel, p_restoran, p_hiburan, p_reklame, p_ppj, p_gol_c, p_abt, p_parkir, status_aktif', 'length', 'max'=>2),
			array('wp', 'length', 'max'=>5),
			array('tanggal_pendataan', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('nomor_urut, no_formulir, npwpd, nama_npwpd, alamat_npwpd, rt_npwpd, rw_npwpd, kelurahan_npwpd, kecamatan_npwpd, kabupaten_npwpd, nopd, tanggal_pendataan, petugas_pendataan, nip_pendataan, petugas_pencatatan, nip_pencatatan, cara_hitung, p_hotel, p_restoran, p_hiburan, p_reklame, p_ppj, p_gol_c, p_abt, p_parkir, wp, status_aktif, user_operator', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'sptpdAirtanahs' => array(self::HAS_MANY, 'SptpdAirtanah', 'nomor_urut'),
			'sptpdHiburans' => array(self::HAS_MANY, 'SptpdHiburan', 'nomor_urut'),
			'sptpdReklames' => array(self::HAS_MANY, 'SptpdReklame', 'nomor_urut'),
			'sptpdRestorans' => array(self::HAS_MANY, 'SptpdRestoran', 'nomor_urut'),
			'suratIzinbWpBus' => array(self::HAS_MANY, 'SuratIzinbWpBu', 'nomor_urut'),
			'sptpdParkirs' => array(self::HAS_MANY, 'SptpdParkir', 'nomor_urut'),
			'sptpdHotels' => array(self::HAS_MANY, 'SptpdHotel', 'nomor_urut'),
			'detailRestorans' => array(self::HAS_MANY, 'DetailRestoran', 'nomor_urut'),
			'detailHotels' => array(self::HAS_MANY, 'DetailHotel', 'nomor_urut'),
			'sptpdGaliancs' => array(self::HAS_MANY, 'SptpdGalianc', 'nomor_urut'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'nomor_urut' => 'Nomor Urut',
			'no_formulir' => 'No Formulir',
			'npwpd' => 'Npwpd',
			'nama_npwpd' => 'Nama Npwpd',
			'alamat_npwpd' => 'Alamat Npwpd',
			'rt_npwpd' => 'Rt Npwpd',
			'rw_npwpd' => 'Rw Npwpd',
			'kelurahan_npwpd' => 'Kelurahan Npwpd',
			'kecamatan_npwpd' => 'Kecamatan Npwpd',
			'kabupaten_npwpd' => 'Kabupaten Npwpd',
			'nopd' => 'Nopd',
			'tanggal_pendataan' => 'Tanggal Pendataan',
			'petugas_pendataan' => 'Petugas Pendataan',
			'nip_pendataan' => 'Nip Pendataan',
			'petugas_pencatatan' => 'Petugas Pencatatan',
			'nip_pencatatan' => 'Nip Pencatatan',
			'cara_hitung' => 'Cara Hitung',
			'p_hotel' => 'P Hotel',
			'p_restoran' => 'P Restoran',
			'p_hiburan' => 'P Hiburan',
			'p_reklame' => 'P Reklame',
			'p_ppj' => 'P Ppj',
			'p_gol_c' => 'P Gol C',
			'p_abt' => 'P Abt',
			'p_parkir' => 'P Parkir',
			'wp' => 'Wp',
			'status_aktif' => 'Status Aktif',
			'user_operator' => 'User Operator',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('nomor_urut',$this->nomor_urut,true);
		$criteria->compare('no_formulir',$this->no_formulir,true);
		$criteria->compare('npwpd',$this->npwpd,true);
		$criteria->compare('nama_npwpd',$this->nama_npwpd,true);
		$criteria->compare('alamat_npwpd',$this->alamat_npwpd,true);
		$criteria->compare('rt_npwpd',$this->rt_npwpd,true);
		$criteria->compare('rw_npwpd',$this->rw_npwpd,true);
		$criteria->compare('kelurahan_npwpd',$this->kelurahan_npwpd,true);
		$criteria->compare('kecamatan_npwpd',$this->kecamatan_npwpd,true);
		$criteria->compare('kabupaten_npwpd',$this->kabupaten_npwpd,true);
		$criteria->compare('nopd',$this->nopd,true);
		$criteria->compare('tanggal_pendataan',$this->tanggal_pendataan,true);
		$criteria->compare('petugas_pendataan',$this->petugas_pendataan,true);
		$criteria->compare('nip_pendataan',$this->nip_pendataan,true);
		$criteria->compare('petugas_pencatatan',$this->petugas_pencatatan,true);
		$criteria->compare('nip_pencatatan',$this->nip_pencatatan,true);
		$criteria->compare('cara_hitung',$this->cara_hitung,true);
		$criteria->compare('p_hotel',$this->p_hotel,true);
		$criteria->compare('p_restoran',$this->p_restoran,true);
		$criteria->compare('p_hiburan',$this->p_hiburan,true);
		$criteria->compare('p_reklame',$this->p_reklame,true);
		$criteria->compare('p_ppj',$this->p_ppj,true);
		$criteria->compare('p_gol_c',$this->p_gol_c,true);
		$criteria->compare('p_abt',$this->p_abt,true);
		$criteria->compare('p_parkir',$this->p_parkir,true);
		$criteria->compare('wp',$this->wp,true);
		$criteria->compare('status_aktif',$this->status_aktif,true);
		$criteria->compare('user_operator',$this->user_operator,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return DataNpwpd the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
